package com.hula.loan4u.adapter;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.hula.loan4u.R;
import com.hula.loan4u.base.MBaseRecyclerAdapter;
import com.hula.loan4u.base.MBaseViewHolder;
import com.hula.loan4u.bean.GoodsBean;
import com.hula.loan4u.utils.ImageLoaderUtil;

import butterknife.BindView;


public class HomeGoodsAdapter extends MBaseRecyclerAdapter<GoodsBean, HomeGoodsAdapter.ViewHolder> {
    public HomeGoodsAdapter(Context context) {
        super(context);
    }

    @Override
    protected void onBindViewHolderEX(ViewHolder holder, int position) {
        holder.setData(getItem(position));
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(mInflater, parent);
    }

    class ViewHolder extends MBaseViewHolder<GoodsBean> {

        @BindView(R.id.goods_img)
        ImageView goodsImg;
        @BindView(R.id.goods_name)
        TextView goodsName;
        @BindView(R.id.goods_money)
        TextView goodsMoney;
        @BindView(R.id.goods_desc)
        TextView goodsDesc;
        @BindView(R.id.goods_btn)
        TextView goodsBtn;
        @BindView(R.id.goods_price_desc)
        TextView goodsPriceDesc;

        public ViewHolder(LayoutInflater mInflater, ViewGroup parent) {
            super(mInflater, parent, R.layout.item_goods);
        }

        @Override
        protected void initView() {

        }

        @Override
        public void setData(GoodsBean data) {
            if (data != null) {
                goodsName.setText(data.productName);
                goodsMoney.setText(data.priceRange);
                goodsDesc.setText(data.desc);
                goodsBtn.setText(data.rightTopic);
                goodsPriceDesc.setText(data.priceDesc);
                ImageLoaderUtil.showImage(goodsImg, data.logoUrl, R.drawable.image_default);
            }
        }
    }
}
